using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Entity;

namespace DAL
{
    public class TypeManagerDAL
    {
        /// <summary>
        /// 配置单件实例
        /// </summary>
        public static readonly TypeManagerDAL Instance = new TypeManagerDAL();
        /// <summary>
        /// 查询类别信息
        /// </summary>
        public List<TypeManager> SelectUserInfo(string where)
        {
            TypeManager user = null;
            List<TypeManager> lstUser = new List<TypeManager>();
            SqlDataReader sdr = null;
            string sql = "select id,name,parent_id,created from type_manager  ";
            if (!string.IsNullOrEmpty(where))
            {
                sql += " where " + where;
            }
            try
            {

                using (sdr =
                    SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,
                    System.Data.CommandType.Text, sql, null))
                {
                    while (sdr.Read())
                    {
                        user = new TypeManager()
                        {
                            ID = sdr.GetInt32(0),
                            Name = sdr.GetString(1),
                            Parent_id = sdr.GetInt32(2),
                            Created  = sdr.GetString(3)
                        };
                        lstUser.Add(user);
                    }
                }
            }
            catch { }
            finally
            {
                if (sdr != null && !sdr.IsClosed)
                    sdr.Close();
            }
            return lstUser;
        }
      
    }
}
